package com.sh.data.engine.domain.workspace.index.model.mapper;

import com.sh.data.engine.domain.workspace.manager.model.domain.StorageDetailDomain;
import com.sh.data.engine.repository.dao.workspace.manager.entity.StorageEntity;
import org.mapstruct.AfterMapping;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;

/**
 * @author: mengzheng.mhc
 * @date: 2024/6/25 9:58
 */
@Mapper(componentModel = "spring")
public interface StorageDetailDomainMapper {

    StorageDetailDomain map(StorageEntity entity);

    @AfterMapping
    default void setRdbmsFields(StorageEntity entity, @MappingTarget StorageDetailDomain domain) {
        StorageEntity.Rmdbs rmdbs = entity.getRmdbs();
        domain.setUsername(rmdbs.getUsername());
        domain.setPassword(rmdbs.getPassword());
        domain.setVersion(rmdbs.getVersion());
        domain.setServer(rmdbs.getServer());
        domain.setPort(rmdbs.getPort());
        domain.setDbName(rmdbs.getDbName());
        domain.setConnectionProperty(rmdbs.getConnectionProperty());
        domain.setSchema(rmdbs.getSchema());
        domain.setHiveSiteAddress(rmdbs.getHiveSiteXmlPath());
        domain.setOriginalFilename(rmdbs.getOriginalFilename());
    }
}
